package com.xieyingwangluo.yxpart.mapper;

import com.xieyingwangluo.yxpart.entity.DemoModel;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface PartCommentMapper {

    /**
     * 新增保存
     * @return
     */
    //@CacheEvict(value="d_user",allEntries = true)
    int add(DemoModel demo);

    /**
     * 编辑用户信息
     * @param user
     */
    //@CacheEvict(value="d_user",allEntries = true)
    @Update("update t_demo set user_code=#{user_code},pwd=#{pwd} where noid=#{noid}")
    int update(DemoModel demo);

    /**
     * 删除用户信息
     * @param noid
     */
    //@CacheEvict(value="d_user",allEntries = true)
    @Delete("delete from t_demo where noid=#{noid}")
    int delete(@Param("noid") String noid);

    /**
     * 修改密码
     */
    //@CacheEvict(value="d_user",allEntries = true)
    @Update("update t_demo set pwd=#{pwd} where noid=#{noid}")
    int updatePassword(DemoModel demo);


    /**
     * 根据id获取用户信息
     * @param noid
     * @return
     */
    //@Cacheable(value="d_demo",key="'UserMapper_getById_'+#noid")
    DemoModel getById(@Param("noid") String noid);

    /**
     * 根据用户名获取用户信息
     * @param usercode
     * @return
     */
    //@Cacheable(value="d_user",key="'UserMapper_getByUsercode_'+#p0")
    @Select("select * from t_demo where user_code=#{user_code}")
    DemoModel getByUsercode(@Param("user_code") String user_code);

    /**
     * 获取用户列表
     * @return
     */
    //@Cacheable(value="d_user",key="'UserMapperlistByUserType'+#p0")
    @Select("select * from t_demo")
    List<DemoModel> list();



}
